package com.pwx.services.impl;

import com.pwx.dao.UserMapper;
import com.pwx.entity.User;
import com.pwx.services.UserServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * Copyright (C),2021-2022,亚瑟王
 * FileName: UserServicesImpl
 * Author: saber
 * Date:2022/10/7 10:43
 */
@Service
@Transactional
public class UserServicesImpl implements UserServices {
    @Autowired
    private UserMapper um;

    @Override
    @Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
    public User doLogin(String userName, String password) {
        User user = um.findUserByName(userName);
        if (user!=null&&user.getPass().equals(password)) {
            return user;
        }
        return null;
    }


    @Override
    public boolean addUser(User user) {
        if (user!=null) {
            return um.addUser(user);
        }
        return false;
    }
}
